package cn.wolfcode.crm.service.impl;/**
 * Created by 10797 on 2018/7/13.
 */

import cn.wolfcode.crm.domain.PaymentBill;
import cn.wolfcode.crm.mapper.PaymentBillMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.IPaymentBillService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: crm
 * @description:
 * @author: Mr.chen
 * @create: 2018-07-13 15:55
 **/
@Service
public class PaymentBillServiceImpl implements IPaymentBillService{

    @Autowired
    private PaymentBillMapper paymentBillMapper;

    @Override
    public void save(PaymentBill entity) {
        paymentBillMapper.insert(entity);
    }

    @Override
    public void update(PaymentBill entity) {
        paymentBillMapper.updateByPrimaryKey(entity);
    }

    @Override
    public void delete(Long id) {
        paymentBillMapper.deleteByPrimaryKey(id);
    }

    @Override
    public PaymentBill get(Long id) {
        return paymentBillMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<PaymentBill> getAll() {
        return paymentBillMapper.selectAll();
    }

    @Override
    public PageResult query(QueryObject qo) {
        int count = paymentBillMapper.queryForCount(qo);
        if(count == 0){
            return  new PageResult();
        }
        List<PaymentBill> list = paymentBillMapper.queryForList(qo);
        return new PageResult(count,list);
    }
}
